import type { CloudFilterBarScheme } from '@/components/filter-bar/types'
import { buildColumns } from '@/utils'

export default function useTableColumn() {
  const filterSchemes = computed<CloudFilterBarScheme>(() => {
    return {
      widgets: [
        {
          widget: 'input',
          field: 'name_keyword',
          showIcon: true,
          placeholder: '请输入域名'
        }
      ]
    }
  })
  const columns = computed(() =>
    buildColumns([
      {
        title: '域名',
        dataIndex: 'name'
      },
      {
        title: 'DNS API名称',
        dataIndex: 'dns_api_name'
      },

      {
        title: '备注',
        dataIndex: 'remark'
      },

      {
        title: '添加时间',
        dataIndex: 'created_at',
        format: 'date-time',
        sortable: sortableSettings
      },
      {
        title: '操作',
        width: 116,
        slotName: 'action',
        cellClass: 'actions-cell'
      }
    ])
  )
  return {
    columns,
    filterSchemes
  }
}
